import itertools
from python_baway.common.xcommon import sep, xshow_table
from python_baway.common.xdb import xdb_args
import python_baway.exercise.mysql.oop.MysqlHelper as MysqlHelper

xconfs = tuple(itertools.product(('users', 'users2'), ('utf8', 'gbk', 'latin1')))
print(xconfs)

for xtable, xcharset in xconfs:
    sep(xtable + ', ' + xcharset)
    kwargs = xdb_args | dict(charset=xcharset)
    print(kwargs)
    helper = MysqlHelper.MysqlHelper(**kwargs)
    xdata = helper.query(f"SELECT * FROM {xtable} ORDER BY id DESC LIMIT 5")
    xshow_table(xdata)
    helper.close()
